package com.daka.vo.response;

import com.daka.entity.Goods;
import lombok.Data;
import lombok.ToString;

import java.math.BigDecimal;

/**
 * Created by yangx
 * CreateTime: 2016/12/28 19:04
 */
@Data
@ToString
public class IndexGoodsVo {

    private Long id;
    private String code;
    private String name;
    private String indexImg;
    private BigDecimal price;

    public static IndexGoodsVo build(Goods goods) {
        IndexGoodsVo indexGoodsVo = new IndexGoodsVo();
        indexGoodsVo.setId(goods.getId());
        indexGoodsVo.setCode(goods.getCode());
        indexGoodsVo.setName(goods.getName());
        indexGoodsVo.setIndexImg(goods.getIndexImg());
        if(goods.getMaxAmount().compareTo(BigDecimal.ZERO) == 0){
            indexGoodsVo.setPrice(goods.getStartAmount());
        }else{
            indexGoodsVo.setPrice(goods.getMaxAmount());
        }

        return indexGoodsVo;
    }
}




